<?php
/**
 * Created by PhpStorm.
 * User: superxing-cto
 * Date: 17/2/9
 * Time: 11:26
 */

namespace App\Models;

/**
 * Class UserIdentity
 * @property integer user_id 用户ID
 * @property string name 姓名
 * @property string identity_no 身份证号
 * @property string front_photo 身份证正面照
 * @property string back_photo 身份证背面照
 * @property string hold_photo 手持身份证照
 * @property User user 关联用户
 */
class UserIdentity extends ApplicationModel
{
    protected $fillable = [
        'user_id',
        'name',
        'identity_no',
        'front_photo',
        'back_photo',
        'hold_photo',
    ];

    static function boot()
    {
        parent::boot();
        static::created(function (UserIdentity $user_identity) {
            $user = $user_identity->user;
            $user->audit = User::AUDITING;
            $user->save();
        });
    }

    public function user()
    {
        return $this->belongsTo(User::class);
    }
}